/**
 * 管理后台首页相关JS
 * author: zhanghua 2015-9-9
 */
$(function(){
	$('#btnpersonal').click(function () {
		var userId = $("#userId").val();
		var nickname = $("#nickname").val();
		var sign = $("#sign").val();
		var img = $("#img")[0].src;
		var provinceId = $("#sheng").val();
		var cityId = $("#shi").val();
		var areaId = $("#qu").val();
		var field = $("#field").val();
		var phone = $("#phone").val();
		var email = $("#email").val();
		var personalOperationNumber = $("#personal_operation_number").val();
		var isAuthor = $("#isAuthor").val();
		var check=$('.hand').find('.check');
		if(nickname == null || nickname == ''){
			alert('会玩号名称不能为空')
			return false;
		}
		if(sign == null || sign == ''){
			alert('会玩号介绍不能为空')
			return false;
		}
		if(img == null || img == ''){
			alert('会玩号头像不能为空')
			return false;
		}
		if(provinceId == null || provinceId == '' || cityId == null || cityId == ''){
			alert('所在地不能为空或则地址不全')
			return false;
		}
		if(field == null || field == ''){
			alert('领域不能为空')
			return false;
		}
		if(phone == null || phone == ''){
			alert('运营者电话不能为空')
			return false;
		}
		if(email == null || email == ''){
			alert('联系邮箱不能为空')
			return false;
		}
		if(!check.hasClass("curr")){
			alert('请阅读并同意会玩号注册协议才能申请')
			return false;
		}
		if(isAuthor == null || isAuthor ==''){
			isAuthor = 0;
		}

		var data = {
			"userId" :userId,
			"nickname": nickname,
			"sign" : sign,
			"img" : img,
			"provinceId" : provinceId,
			"cityId" : cityId,
			"areaId" : areaId,
			"field" : field,
			"phone" : phone,
			"email" : email,
			"personalOperationNumber" : personalOperationNumber,
			'isAuthor' : isAuthor,
		};
		var postUrl = $('#postPersonalDataUrl').val()
		var jumpUrl = $('#jumpUrl').val();
		var authorJumpUrl = $('#authorJumpUrl').val();

		post_json(postUrl, data ,function(res){
			switch(res.status){
				case 1:
					if(isAuthor){
						location.href = authorJumpUrl;
					}else{
						location.href = jumpUrl;
					}
					break;
				case 0:
					alert(res.msg);
					break;
			}
		});
		return false;
	});
});


